package com.party.core.service.photo.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.photo.PhotosImgTagReadDao;
import com.party.core.dao.write.photo.PhotosImgTagWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.photo.PhotosImgTag;
import com.party.core.service.photo.IPhotosImgTagService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @Description:
 * @Author: yangshoukun
 * @Date: 2018/5/30 14:28
 */
@Service
public class PhotosImgTagService implements IPhotosImgTagService {

    @Autowired
    private PhotosImgTagReadDao photosImgTagReadDao;

    @Autowired
    private PhotosImgTagWriteDao photosImgTagWriteDao;

    @Override
    public String insert(PhotosImgTag photosImgTag) {
        BaseModel.preInsert(photosImgTag);
        boolean result = photosImgTagWriteDao.insert(photosImgTag);
        if (result){
            return photosImgTag.getId();
        }
        return null;
    }

    @Override
    public boolean update(PhotosImgTag photosImgTag) {
        return photosImgTagWriteDao.update(photosImgTag);
    }

    @Override
    public boolean deleteLogic(String id) {
        if (Strings.isNullOrEmpty(id)){
            return false;
        }
        return photosImgTagWriteDao.deleteLogic(id);
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)){
            return false;
        }
        return photosImgTagWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)){
            return false;
        }
        return photosImgTagWriteDao.batchDeleteLogic(ids);
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)){
            return false;
        }
        return photosImgTagWriteDao.batchDelete(ids);
    }

    @Override
    public PhotosImgTag get(String id) {
        return photosImgTagReadDao.get(id);
    }

    @Override
    public List<PhotosImgTag> listPage(PhotosImgTag photosImgTag, Page page) {
        return photosImgTagReadDao.listPage(photosImgTag, page);
    }

    @Override
    public List<PhotosImgTag> list(PhotosImgTag photosImgTag) {
        return listPage(photosImgTag, null);
    }

    @Override
    public List<PhotosImgTag> batchList(Set<String> ids, PhotosImgTag photosImgTag, Page page) {
        return null;
    }

    @Override
    public List<PhotosImgTag> listFindInSet(PhotosImgTag photosImgTag) {
        return photosImgTagReadDao.listFindInSet(photosImgTag);
    }

    @Override
    public void deleteByPhotoId(String photoId) {
        photosImgTagWriteDao.deleteByPhotoId(photoId);
    }
}
